{% extends "base.html" %}

{% block body %}

<div style="margin-top:5px" class="card border border-dark shadow bg-card-body" id="manualFileTable">
    <div class="card-header bg-header border border-dark shadow text-white">
        <h2 style="display:inline-block">Current <span class="operator">Manual File</span> Uploads</h2>
        <button style="float:right" type="button" class="btn btn{{config['outline-buttons']}}primary btn-md" onclick="create_file_button()"><i class="fas fa-plus"></i> File</button>
    </div>
    <div class="card-body bg-card-body shadow border border-dark">
        These files can be downloaded via the download button or by hitting {{http}}://{{links.server_ip}}:{{links.server_port}}{{links.api_base}}/files/download/[File UUID] .
    </div>
        <table class="table table-condensed table-striped {{config['table-color']}}" style="margin-bottom:0">
            <tr>
                <th style="width:4rem"><b>Delete</b></th>
                <th style="width:5rem"><b>Download</b></th>
                <th style="width:15rem" onclick="sort_table(this, 'date')"><b>Time</b></th>
                <th style="width:22rem" onclick="sort_table(this)"><b>File UUID</b></th>
                <th style="width:10rem;text-align:left" onclick="sort_table(this)"><b>Uploader</b></th>
                <th style="text-align:left" onclick="sort_table(this)"><b>File</b></th>
                <th style="width:24rem"><b>Hashes</b></th>
            </tr>
        <!-- Repeat this for each web service -->
            <tr v-for="file in files" :key="file.id">
                <td style="text-align:center">
                    <button type="button" class="btn btn{{config['outline-buttons']}}danger btn-sm" @click="delete_button(file.id)"><i class="fas fa-trash-alt"></i></button>
                </td>
                <td style="text-align:center">
                    <button type="button" class="btn btn{{config['outline-buttons']}}success btn-sm" @click="download_button(file.agent_file_id)"><i class="fas fa-download"></i></button>
                </td>
                <td>[[ toLocalTime(file.timestamp) ]]</td>
                <td>[[ file.agent_file_id ]]</td>
                <td>[[ file.operator ]]</td>
                <td>[[ file.filename ]]</td>
                <td>
                    MD5: [[file.md5]]<br>
                    SHA1: [[file.sha1]]
                </td>
            </tr>
        <!-- End of the repeating -->
        </table>
</div>

<!-- THIS IS OUR MODAL FOR NEW MANUAL FILE MENU -->
<div class="modal fade" id="manualFileModal" role="dialog">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header bg-dark text-white">
                <h3>Manually Host File</h3>
                <button type="button" class="close" data-dismiss="modal">×</button>
            </div>
              <div class="modal-body">
                  Manually register a file into the database for use with agents with either a local file or uploading one.
                <table class="table table-striped {{config['table-color']}}">
                    <tr>
                        <td>
                            <input class="form-control-file" type="file" id="manualFileUpload">
                        </td>
                    </tr>
                </table>
              </div>
              <div class="modal-footer">
                <button class="btn btn{{config['outline-buttons']}}warning" data-dismiss="modal" aria-hidden="true">Cancel</button>
                <button class="btn btn{{config['outline-buttons']}}primary" data-dismiss="modal" id="manualFileSubmit">Submit</button>
              </div>
        </div>
    </div>
</div>
<!-- END MODAL FOR NEW MANUAL FILE MENU -->
{% endblock %}

{% block scripts %}
{% include "services_host_file.js" %}
{% endblock %}

{% block body_config %}

{% endblock %}